<template>
  <div class="block">
    <div v-if="!postersManage">
      <Error></Error>
    </div>
    <div v-if="postersManage">
      <!--详情-->
      <el-drawer id="drawer"
                 size="45%"
                 title="文章详情"
                 :visible.sync="drawer"
                 :direction="direction"
                 :before-close="handleClose">
        <div class="drawerDiv">
          <p><label>文章内容：</label><span>{{detailsData.content || '暂未设置'}}</span></p>
          <p><label>发布状态：</label><span>{{detailsData.status || '暂未设置'}}</span></p>
          <p><label>热门状态：</label><span>{{detailsData.is_hot || '暂未设置'}}</span></p>
          <!--<p><label>推荐状态：</label><span>{{detailsData.is_recommend || '暂未设置'}}</span></p>-->
          <p><label>所属项目：</label><span>{{detailsData.project || '暂未设置'}}</span></p>
          <p><label>图片详情：</label>
            <span style="display: block;margin-left: 110px">
           　<img v-for="(item,index) in detailsData.img_url" :src="item" :key="index" width="100" style="margin-left: 5px"/>
          </span>
          </p>
          <p><label>创建时间：</label><span>{{detailsData.create_time || '暂未设置'}}</span></p>

        </div>
      </el-drawer>
      <!--编辑弹框-->
      <el-dialog title="添加文章" :visible.sync="dialogFormVisible">
        <el-form :model="formDate" label-width="100px" ref="formDate">
          <el-form-item label="内容编辑" label-width="100px">
            <el-input style="width: 620px" type="textarea" v-model="formDate.desc" :autosize="{ minRows: 10}" placeholder="请输入内容"></el-input>
          </el-form-item>
          <el-form-item label="图片编辑" label-width="100px">
            <el-upload
              action="#"
              ref='upload'
              :limit = "9"
              :auto-upload="false"
              :before-upload="beforeAvatarUpload"
              :on-change="getFile"
              list-type="picture-card"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogVisible">
              <img width="100%" :src="dialogImageUrl" alt="">
            </el-dialog>
          </el-form-item>
          <el-form-item label="排序" label-width="100px" style="width: 390px">
            <el-input v-model="formDate.sort" type="text" maxlength="2" placeholder="请输入1~99的正整数"
                      oninput="if(this.value=='0'){this.value='';}else{this.value=this.value.replace(/[^0-9]/g,'')}"
            ></el-input>
          </el-form-item>
          <el-form-item label="是否发布" label-width="100px" style="margin-bottom: 0">
            <el-radio-group v-model="formDate.exhibition">
              <el-radio label="1">不发布</el-radio>
              <el-radio label="2">发布</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="是否热卖" label-width="100px" style="margin-bottom: 0">
            <el-radio-group v-model="formDate.bestSeller">
              <el-radio label="1">不热门</el-radio>
              <el-radio label="2">热门</el-radio>
            </el-radio-group>
          </el-form-item>
          <!--<el-form-item label="是否推荐" label-width="100px" style="margin-bottom: 0">-->
            <!--<el-radio-group v-model="formDate.recommend">-->
              <!--<el-radio label="1">不推荐</el-radio>-->
              <!--<el-radio label="2">推荐</el-radio>-->
            <!--</el-radio-group>-->
          <!--</el-form-item>-->
          <el-form-item label="所属项目" label-width="100px">
            <el-radio-group v-model="formDate.posters">
              <el-radio v-for="(item,key,index) in posters_arr" :label="key" :key="index">{{item}}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitFormDate()">确 定</el-button>
        </div>
      </el-dialog>
      <div class="inquireDiv">
        <p>
          <label><span>发布状态：</span>
            <el-select v-model="form.issueStatus" placeholder="请选择发布状态">
              <el-option label="全部" value="0"></el-option>
              <el-option label="发布" value="2"></el-option>
              <el-option label="不发布" value="1"></el-option>
            </el-select>
          </label>
          <label><span>热门状态：</span>
            <el-select v-model="form.hotStatus" placeholder="请选择热门状态">
              <el-option label="全部" value="0"></el-option>
              <el-option label="热门" value="2"></el-option>
              <el-option label="不热门" value="1"></el-option>
            </el-select>
          </label>
          <label><span>所属项目：</span>
            <el-select v-model="form.project" placeholder="请选择状态">
              <el-option label="全部" value="0"></el-option>
              <el-option v-for="(item,key,index) in posters_arr" :label="item" :value="key" :key="index"></el-option>
            </el-select>
          </label>
          <el-button type="primary" @click="examineFn" style="float: right">查 询</el-button>
        </p>
      </div>
      <div class="tableDiv" v-loading="loading">
        <el-row>
          <el-table
            :cell-class-name="addClass"
            @select="selectChange"
            @select-all="selectChange"
            :data="tableData"
            border
            stripe>
            <el-table-column
              type="selection"
              align="center"
              width="55">
            </el-table-column>
            <el-table-column
              prop="content"
              label="文字描述"
              :show-overflow-tooltip='true'
              width="250">
            </el-table-column>
            <el-table-column
              label="图片列表"
              width="300">
              <template slot-scope="scope">
                　　　　<img v-for="(item,index) in scope.row.img_id" :src="item" :key="index" width="80" style="margin-left: 5px;vertical-align: middle"/>
                <i v-if='scope.row.img_count > 3' class="el-icon-more" style="margin-left: 5px"></i>
              </template>
            </el-table-column>
            <el-table-column
              prop="name"
              align="center"
              label="发布状态"
              width="80">
              <template slot-scope="scope">
                <span style="color:#67C23A" v-if="scope.row.status === 2">发布</span>
                <span style="color:#F56C6C" v-if="scope.row.status === 1">不发布</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="name"
              align="center"
              label="热卖状态"
              width="80">
              <template slot-scope="scope">
                <span style="color:#67C23A" v-if="scope.row.is_hot === 2">热门</span>
                <span style="color:#F56C6C" v-if="scope.row.is_hot === 1">不热门</span>
              </template>
            </el-table-column>
            <!--<el-table-column-->
              <!--prop="name"-->
              <!--align="center"-->
              <!--label="推荐状态"-->
              <!--width="80">-->
              <!--<template slot-scope="scope">-->
                <!--<span style="color:#67C23A" v-if="scope.row.is_recommend === 2">推荐</span>-->
                <!--<span style="color:#F56C6C" v-if="scope.row.is_recommend === 1">不推荐</span>-->
              <!--</template>-->
            <!--</el-table-column>-->

            <el-table-column
              prop="project"
              label="所属项目"
              align="center"
              width="100"
            >
            </el-table-column>
            <el-table-column
              prop="create_time"
              sortable
              label="创建时间"
              align="center"
              width="160"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
              align="center">
              <template slot="header" slot-scope="scope">
                <div class="el-table-header">
                  <el-button type="primary" @click.native.prevent="addInformation">添加文章</el-button>
                  <el-button type="primary" @click.native.prevent="batchDisplay">批量发布</el-button>
                </div>
              </template>
              <template slot-scope="scope">
                <el-button
                  @click.native.prevent="detailsRow(scope.$index,tableData)"
                  type="primary"
                  size="small">
                  详情
                </el-button>
                <el-button v-show="scope.row.status !== 1"
                           @click.native.prevent="showRow(scope.$index,tableData,1,1,1)"
                           type="warning"
                           size="small">
                  不发布
                </el-button>
                <el-button v-show="scope.row.status === 1"
                           @click.native.prevent="showRow(scope.$index,tableData,2,2,1)"
                           type="success"
                           size="small">
                  发布
                </el-button>
                <el-button v-show="scope.row.is_hot !== 1"
                           @click.native.prevent="showRow(scope.$index,tableData,1,3,3)"
                           type="warning"
                           size="small">
                  不热门
                </el-button>
                <el-button v-show="scope.row.is_hot === 1"
                           @click.native.prevent="showRow(scope.$index,tableData,2,4,3)"
                           type="success"
                           size="small">
                  热门
                </el-button>
                <!--<el-button v-show="scope.row.is_recommend !== 1"-->
                           <!--@click.native.prevent="showRow(scope.$index,tableData,1,5,2)"-->
                           <!--type="warning"-->
                           <!--size="small">-->
                  <!--不推荐-->
                <!--</el-button>-->
                <!--<el-button v-show="scope.row.is_recommend === 1"-->
                           <!--@click.native.prevent="showRow(scope.$index,tableData,2,6,2)"-->
                           <!--type="success"-->
                           <!--size="small">-->
                  <!--推荐-->
                <!--</el-button>-->
                <!--<el-button-->
                  <!--@click.native.prevent="deleteRow(scope.$index,tableData)"-->
                  <!--type="danger"-->
                  <!--size="small">-->
                  <!--删除-->
                <!--</el-button>-->
              </template>
            </el-table-column>
          </el-table>
          <el-col :span="24">
            <div class="block" v-if="total">
              <el-pagination
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-size="10"
                layout="total, prev, pager, next"
                :total="total">
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
  import Error from '../errorPage/errorPage401'
  export default {
    data() {
      return {
        mid: '',
        uid:'',
        loading: true,
        currentPage: '',
        form: {
          issueStatus:'',
          hotStatus:'',
          project:'',
        },
        tableData: [],
        total: '',
        postersManage:false,
        dialogFormVisible:false,
        formDate:{
          desc:'',
          imageUrl:[],
          exhibition:'1',
          bestSeller:'1',
          recommend:'1',
          posters:'',
          sort:''
        },

        dialogImageUrl: '',
        dialogVisible: false,

        drawer: false,
        direction: 'rtl',
        detailsData: [],

        selectDateArr:[],
        posters_arr:[]
      }
    },
    methods: {
      //初始化
      initFn: function (page) {
        let data = {
          page: page,
          status:this.form.issueStatus,
          hot:this.form.hotStatus,
          project:this.form.project,
        };
        let str = this.encryptionAesRsa(data);
        let encryptData = str.split('%$#@zjt@#$%')[0];
        let encryptKey = str.split('%$#@zjt@#$%')[1];
        let incomData = {
          map: 'api_article_List',
          plum_session_api: localStorage.getItem('token'),
          encryptData: encryptKey,
          encryptKey: encryptData
        };
        this.$http.post('', incomData).then((data) => {
          if (data.ec == 200) {
            this.loading = false;
            this.total = Number(data.data.count);
            this.currentPage = Number(data.data.page);
            this.tableData = data.data.list;
            this.posters_arr = data.data.posters_arr;
          } else if (data.ec == 401) {
            this.$message.error(data.em);
            setTimeout(() => {
              this.exitLogin();
            }, 1500)
          } else {
            this.$message.error(data.em);
          }
        }).catch((err) => {
          this.$message.error('error!');
        })
      },
      //上传图片
      beforeAvatarUpload(file) {
        console.log(file)
      },
      handleRemove() {
        this.$refs.upload.clearFiles()
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url;
        this.dialogVisible = true;
      },
      getFile(file,fileList){
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 2MB!');
          fileList.pop()
        }else {
          this.getBase64(file.raw).then(res=>{
            this.imgUpFn(res)
          })
        }

      },
      getBase64:function(file){
        return new Promise(function(resolve,reject){
          let reader=new FileReader();
          let imgResult="";
          reader.readAsDataURL(file);
          reader.onload=function(){
            imgResult=reader.result;
          };
          reader.onerror=function(error){
            reject(error);
          };
          reader.onloadend=function(){
            resolve(imgResult);
          }
        })
      },
      imgUpFn:function(imgUrl){
        let data = {
          image: imgUrl,
        };
        let str = this.encryptionAesRsa(data);
        let encryptData = str.split('%$#@zjt@#$%')[0];
        let encryptKey = str.split('%$#@zjt@#$%')[1];
        let incomData = {
          map: 'api_posters_upload',
          plum_session_api: localStorage.getItem('token'),
          encryptData: encryptKey,
          encryptKey: encryptData
        };
        this.$http.post('', incomData).then((data) => {
          if (data.ec == 200) {
            this.$message.success(data.em);
            let str = data.path;
            this.formDate.imageUrl.push(str);
          } else if (data.ec == 401) {
            this.$message.error(data.em);
            setTimeout(() => {
              this.exitLogin();
            }, 1500)
          } else {
            this.$message.error(data.em);
          }
        }).catch((err) => {
          this.$message.error('error!');
        })
      },
      //查询
      examineFn: function () {
        this.initFn(1)
      },
      //列变色
      addClass({row, column, rowIndex, columnIndex}) {
        if (columnIndex === 6) {
          return 'cell-blue'
        }
      },
      //点击分页
      handleCurrentChange(val) {
        this.$router.replace({
          path: this.$route.path,
          query: {
            page: val,
          }
        });
        this.loading = true;
        this.initFn(val);
      },
      //点击详情
      detailsRow(index, row) {
        this.drawer = true;
        this.uid = row[index].id;
        this.confirmUser();
      },
      //获取详情
      confirmUser: function () {
        let data = {
          id: this.uid,
        };
        let str = this.encryptionAesRsa(data);
        let encryptData = str.split('%$#@zjt@#$%')[0];
        let encryptKey = str.split('%$#@zjt@#$%')[1];
        let incomData = {
          map: 'api_article_detail',
          plum_session_api: localStorage.getItem('token'),
          encryptData: encryptKey,
          encryptKey: encryptData
        };
        this.$http.post('', incomData).then((data) => {
          if (data.ec == 200) {
            this.detailsData = data.data
          } else if (data.ec == 401) {
            this.$message.error(data.em);
            setTimeout(() => {
              this.exitLogin();
            }, 1500)
          } else {
            this.$message.error(data.em);
          }
        }).catch((err) => {
          this.$message.error('error!');
        })
      },
      //关闭详情弹窗
      handleClose(done) {
        done();
      },
      // // 展示/不展示按钮
      // showRow(index, row, status) {
      //   let str = '';
      //   if (status == 1) {
      //     str = '此操作将该条海报改为展示, 是否继续?'
      //   } else {
      //     str = '此操作会将该条海报改为不展示, 是否继续?'
      //   }
      //   this.$confirm(str, '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.mid = row[index].mbc_id;
      //     let data = {
      //       mbc_id: this.mid,
      //       status: status
      //     };
      //     let str = this.encryptionAesRsa(data);
      //     let encryptData = str.split('%$#@zjt@#$%')[0];
      //     let encryptKey = str.split('%$#@zjt@#$%')[1];
      //     let incomData = {
      //       map: 'admin_mer_config_status',
      //       plum_session_api: localStorage.getItem('token'),
      //       encryptData: encryptKey,
      //       encryptKey: encryptData
      //     };
      //     this.$http.post('', incomData).then((data) => {
      //       if (data.ec == 200) {
      //         this.$message.success(data.em);
      //         this.initFn(this.currentPage)
      //       } else if (data.ec == 401) {
      //         this.$message.error(data.em);
      //         setTimeout(() => {
      //           this.exitLogin();
      //         }, 1500)
      //       } else {
      //         this.$message.error(data.em);
      //       }
      //     }).catch((err) => {
      //       this.$message.error('error!');
      //     })
      //   }).catch(() => {
      //     this.$message({
      //       type: 'info',
      //       message: '已取消操作'
      //     });
      //   });
      // },
      // // 热卖/不热卖按钮
      // bestRow(index, row, status) {
      //   let str = '';
      //   if (status == 1) {
      //     str = '此操作将该条海报改为热卖, 是否继续?'
      //   } else {
      //     str = '此操作会将该条海报改为不热卖, 是否继续?'
      //   }
      //   this.$confirm(str, '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.mid = row[index].mbc_id;
      //     let data = {
      //       mbc_id: this.mid,
      //       status: status
      //     };
      //     let str = this.encryptionAesRsa(data);
      //     let encryptData = str.split('%$#@zjt@#$%')[0];
      //     let encryptKey = str.split('%$#@zjt@#$%')[1];
      //     let incomData = {
      //       map: 'admin_mer_config_status',
      //       plum_session_api: localStorage.getItem('token'),
      //       encryptData: encryptKey,
      //       encryptKey: encryptData
      //     };
      //     this.$http.post('', incomData).then((data) => {
      //       if (data.ec == 200) {
      //         this.$message.success(data.em);
      //         this.initFn(this.currentPage)
      //       } else if (data.ec == 401) {
      //         this.$message.error(data.em);
      //         setTimeout(() => {
      //           this.exitLogin();
      //         }, 1500)
      //       } else {
      //         this.$message.error(data.em);
      //       }
      //     }).catch((err) => {
      //       this.$message.error('error!');
      //     })
      //   }).catch(() => {
      //     this.$message({
      //       type: 'info',
      //       message: '已取消操作'
      //     });
      //   });
      // },
      // // 推荐/不推荐按钮
      // recommendRow(index, row, status) {
      //   let str = '';
      //   if (status == 1) {
      //     str = '此操作将该条海报改为推荐, 是否继续?'
      //   } else {
      //     str = '此操作会将该条海报改为不推荐, 是否继续?'
      //   }
      //   this.$confirm(str, '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.mid = row[index].mbc_id;
      //     let data = {
      //       mbc_id: this.mid,
      //       status: status
      //     };
      //     let str = this.encryptionAesRsa(data);
      //     let encryptData = str.split('%$#@zjt@#$%')[0];
      //     let encryptKey = str.split('%$#@zjt@#$%')[1];
      //     let incomData = {
      //       map: 'admin_mer_config_status',
      //       plum_session_api: localStorage.getItem('token'),
      //       encryptData: encryptKey,
      //       encryptKey: encryptData
      //     };
      //     this.$http.post('', incomData).then((data) => {
      //       if (data.ec == 200) {
      //         this.$message.success(data.em);
      //         this.initFn(this.currentPage)
      //       } else if (data.ec == 401) {
      //         this.$message.error(data.em);
      //         setTimeout(() => {
      //           this.exitLogin();
      //         }, 1500)
      //       } else {
      //         this.$message.error(data.em);
      //       }
      //     }).catch((err) => {
      //       this.$message.error('error!');
      //     })
      //   }).catch(() => {
      //     this.$message({
      //       type: 'info',
      //       message: '已取消操作'
      //     });
      //   });
      // },
      // 展示/不展示按钮
      showRow(index, row, status,strs,type) {
        let str = '';
        switch(strs){
          case 1:
            str = '此操作将该条海报改为不发布, 是否继续?';
            break;
          case 2:
            str = '此操作会将该条海报改为发布, 是否继续?';
            break;
          case 3:
            str = '此操作会将该条海报改为不热门, 是否继续?';
            break;
          case 4:
            str = '此操作会将该条海报改为热门, 是否继续?';
            break;
          case 5:
            str = '此操作会将该条海报改为不推荐, 是否继续?';
            break;
          case 6:
            str = '此操作会将该条海报改为推荐, 是否继续?';
            break;
        }
        this.$confirm(str, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.mid = row[index].id;
          let data = {
            type:type,
            id: this.mid,
            status: status
          };
          let str = this.encryptionAesRsa(data);
          let encryptData = str.split('%$#@zjt@#$%')[0];
          let encryptKey = str.split('%$#@zjt@#$%')[1];
          let incomData = {
            map: 'api_article_update',
            plum_session_api: localStorage.getItem('token'),
            encryptData: encryptKey,
            encryptKey: encryptData
          };
          this.$http.post('', incomData).then((data) => {
            if (data.ec == 200) {
              this.$message.success(data.em);
              this.initFn(this.currentPage)
            } else if (data.ec == 401) {
              this.$message.error(data.em);
              setTimeout(() => {
                this.exitLogin();
              }, 1500)
            } else {
              this.$message.error(data.em);
            }
          }).catch((err) => {
            this.$message.error('error!');
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          });
        });
      },
      // //  删除
      // deleteRow(index, row, status){
      //   this.$confirm("此操作将删除该海报, 是否继续?", '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(() => {
      //     this.mid = row[index].mbc_id;
      //     let data = {
      //       mbc_id: this.mid,
      //       status: status
      //     };
      //     let str = this.encryptionAesRsa(data);
      //     let encryptData = str.split('%$#@zjt@#$%')[0];
      //     let encryptKey = str.split('%$#@zjt@#$%')[1];
      //     let incomData = {
      //       map: 'admin_mer_config_status',
      //       plum_session_api: localStorage.getItem('token'),
      //       encryptData: encryptKey,
      //       encryptKey: encryptData
      //     };
      //     this.$http.post('', incomData).then((data) => {
      //       if (data.ec == 200) {
      //         this.$message.success(data.em);
      //         this.initFn(this.currentPage)
      //       } else if (data.ec == 401) {
      //         this.$message.error(data.em);
      //         setTimeout(() => {
      //           this.exitLogin();
      //         }, 1500)
      //       } else {
      //         this.$message.error(data.em);
      //       }
      //     }).catch((err) => {
      //       this.$message.error('error!');
      //     })
      //   }).catch(() => {
      //     this.$message({
      //       type: 'info',
      //       message: '已取消删除'
      //     });
      //   });
      // },
      //添加海报
      addInformation:function () {
        this.dialogFormVisible = true;
      },
      //选中的值
      selectChange:function(selection, row){
        this.selectDateArr = [];
        selection.forEach(ro =>{
          this.selectDateArr.push(ro.id)
        })
      },
      //批量发布
      batchDisplay:function(){
          this.$confirm('此操作将选中数据批量发布, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            if(this.selectDateArr.length > 0 ){
              let data = {
                id:this.selectDateArr,
              };
              let str = this.encryptionAesRsa(data);
              let encryptData = str.split('%$#@zjt@#$%')[0];
              let encryptKey = str.split('%$#@zjt@#$%')[1];
              let incomData = {
                map: 'api_article_BatchRelease',
                plum_session_api: localStorage.getItem('token'),
                encryptData: encryptKey,
                encryptKey: encryptData
              };
              this.$http.post('', incomData).then((data) => {
                if (data.ec == 200) {
                  this.$message.success(data.em);
                  this.selectDateArr = [];
                  this.initFn(this.currentPage)
                } else if (data.ec == 401) {
                  this.$message.error(data.em);
                  setTimeout(() => {
                    this.exitLogin();
                  }, 1500)
                } else {
                  this.$message.error(data.em);
                }
              }).catch((err) => {
                this.$message.error('error!');
              })
            }else {
              this.$message.error('请先勾选需要发布的信息');
            }
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消操作'
            });
          });
      },

      //确定添加海报
      submitFormDate(){
        if(this.formDate.posters){
          let data = {
            content:this.formDate.desc,
            image:this.formDate.imageUrl,
            sort:this.formDate.sort,
            status:this.formDate.exhibition,
            project:this.formDate.posters,
            is_recommend:this.formDate.recommend,
            is_hot:this.formDate.bestSeller,
          };
          let str = this.encryptionAesRsa(data);
          let encryptData = str.split('%$#@zjt@#$%')[0];
          let encryptKey = str.split('%$#@zjt@#$%')[1];
          let incomData = {
            map: 'api_article_insert',
            plum_session_api: localStorage.getItem('token'),
            encryptData: encryptKey,
            encryptKey: encryptData
          };
          this.$http.post('', incomData).then((data) => {
            if (data.ec == 200) {
              this.$message.success(data.em);
              this.initFn(this.currentPage);
              this.dialogFormVisible = false;
              this.formDate.desc = '';
              this.formDate.imageUrl = [];
              this.formDate.exhibition = '1';
              this.formDate.bestSeller = '1';
              this.formDate.recommend = '1';
              this.formDate.posters = '';
              this.formDate.sort = '';
              this.$refs.upload.clearFiles();
            } else if (data.ec == 401) {
              this.$message.error(data.em);
              setTimeout(() => {
                this.exitLogin();
              }, 1500)
            } else {
              this.$message.error(data.em);
            }
          }).catch((err) => {
            this.$message.error('error!');
          })
        }else {
          this.$message.error('请选择所属项目');
        }
      }
    },
    mounted() {
      this.currentPage = this.$route.query.page ? this.$route.query.page : 1;
      this.initFn(this.currentPage);
      // 按钮权限
      let buttonMenu = localStorage.getItem('buttonMenu');
      buttonMenu = this.edecryptButton(buttonMenu);
      //页面权限
      if (buttonMenu.indexOf('postersManage') !== -1) {
        this.postersManage = true
      }
    },
    components:{
      Error
    }
  }
</script>

<style scoped>
  .inquireDiv {
    padding: 30px;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
  }

  .inquireDiv label {
    display: inline-block;
    margin-left: 50px;
  }
  .inquireDiv label span{
    width: 80px;
    display: inline-block;
  }

  .inquireDiv .el-input {
    width: 220px;
  }

  .tableDiv {
    margin-top: 20px;
  }

  .el-col {
    border-radius: 4px;
    height: 75px;
    background-color: #fff;
  }

  .tableDiv >>> .el-pagination {
    height: 30px;
    line-height: 30px;
    margin-top: 25px;
    text-align: center;
  }

  .tableDiv >>> .cell-blue {
    color: #409EFF !important;
  }

  .drawerDiv {
    width: 100%;
    height: calc(90vh);
    padding: 20px;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .drawerDiv h2 {
    text-align: center;
    font-size: 20px;
    margin: 20px 0;
  }
  #drawer p img {
    width: 200px;
    margin: 10px;
    vertical-align: middle;
  }

  .drawerDiv p {
    font-size: 16px;
    color: #000000;
    margin-top: 10px;
  }

  .drawerDiv p label {
    font-size: 16px;
    vertical-align: middle;
    font-weight: 600;
    display: inline-block;
    width: 80px;
    text-align: right;
  }

  .drawerDiv p span {
    font-size: 14px;
    vertical-align: middle;
    color: #555555;
    margin-left: 5px;
    display: inline-block;
    width: calc(100% - 100px);
  }

  .el-table-header >>> .el-button {
    float: left;
    height: 40px;
  }
  .block >>> .el-dialog {
    width: 830px;
  }


  .block >>> .uploadingImage{
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    width: 250px;
    height: 300px;
    display: inline-block;
    vertical-align: middle;
    transition: all .2s;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center center;

  }
  .block >>> .uploadingImage:hover{
    border: 1px dashed #409EFF;
  }
  .block >>> .uploadingImage i{
    font-size: 30px !important;
    color: #555555;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -16px;
    margin-top: -15px;
  }
  .block >>> .el-upload--picture-card{
    width: 150px;
    height: 266px;
    line-height: 266px;
  }
  .block >>> .el-upload-list--picture-card .el-upload-list__item{
    width: 150px;
    height: 266px;
  }
  .block >>> .el-upload-list--picture-card .el-upload-list__item-actions{
    display: none;
  }
</style>



